package br.com.mftec;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;

public class TratarXML {
	TratarXML(){
	}

	/**
	 * <?xml version='1.0' encoding='UTF-8'?>
	 * 	<pacote versao='1.0' rastreadora='AAATTT00'>
	 *     <sinal id='1011' x='-44.5000' y='-22.5000' vel='24.0' data='2011-5-27 12:33:44'/>
	 * 	</pacote>  
	 */
	public String MontarXML(String versao,String rastreadora, 
			String id_sinal, String x, String y, String velocidade, String data){
		Element pacote = new Element("pacote");
		pacote.setAttribute("versao", versao);
		pacote.setAttribute("rastreadora", rastreadora);

		Element sinal = new Element("sinal");
		sinal.setAttribute("id", id_sinal);
		sinal.setAttribute("x", x);
		sinal.setAttribute("y", y);
		sinal.setAttribute("vel", velocidade);
		sinal.setAttribute("data", data);

		Document documento = new Document(pacote);

		pacote.addContent(sinal);

		documento.setRootElement(pacote);

		XMLOutputter xout = new XMLOutputter();  
		return xout.outputString(documento);
	}
}
